package com.xdja.myapplication.demo.viewpager

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.viewpager.widget.ViewPager
import com.xdja.myapplication.R
import kotlinx.android.synthetic.main.activity_view_pager.*
import kotlinx.android.synthetic.main.motion_viewpager.*

class ViewPagerActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_view_pager)


        val adapter = ViewPagerAdapter(supportFragmentManager)
        adapter.addPage("早上", R.layout.viewpager_page1)
        adapter.addPage("中午", R.layout.viewpager_page2)
        adapter.addPage("晚上", R.layout.viewpager_page3)
        pager.adapter = adapter
        tabs.setupWithViewPager(pager)
        if (motionLayout != null) {
            pager.addOnPageChangeListener(motionLayout as ViewPager.OnPageChangeListener)
        }
    }
}
